import Vue from 'vue'
import CryptoJS from 'crypto-js'
import forge from 'node-forge'


const key = "lzjy_@365A123456";
const iv = "lzjy_@365A123456";
/**
 * AES加密 ：字符串 key iv  返回base64 
 */
export function Encrypt(data) {
  let asmcryptoJS = require('asmcrypto.js');
  const encoder = new TextEncoder()
  const key = encoder.encode("3231672C316BFADCE8759EC695DC17D4");
  const iv = encoder.encode("3231672C316B");
  const msg = encoder.encode(data);
  return asmcryptoJS.AES_GCM.encrypt(msg, key, iv);
}
/**
 * AES 解密 ：字符串 key iv  返回base64 
 *
 */
export function Decrypt(data) {
  let asmcryptoJS = require('asmcrypto.js');
  const encoder = new TextEncoder()
  let utf8decoder = new TextDecoder();
  const key = encoder.encode("3231672C316BFADCE8759EC695DC17D4");
  const iv = encoder.encode("3231672C316B");
  let result = asmcryptoJS.AES_GCM.decrypt(data, key, iv);
  return utf8decoder.decode(result);

}

